/**
 * @file conn.h
 * @author HaoyuWang (136046355@qq.com)
 * @brief socket连接对象
 * @version 0.1
 * @date 2025-02-05
 * 
 * @copyright Copyright (c) 2025
 * 
 */

#ifndef __CONN_H__
#define __CONN_H__


#include <cstdint>
#include <memory>

#include "conn_writer.h"
#include "conn_reader.h"


class Conn
{
public:
    enum Type{
        LISTEN = 1,
        CLIENT = 2,
    };

public:
    Conn();
    ~Conn();

    inline void SetType(Conn::Type type){
        type_ = type;
    }
    inline Conn::Type GetType(){
        return type_;
    }

    inline void SetFd(int fd){
        fd_ = fd;
        writer_->SetFd(fd);
        reader_->SetFd(fd);
    }
    inline int GetFd(){
        return fd_;
    }

    inline void SetServiceID(uint32_t id){
        service_id_ = id;
    }
    inline uint32_t GetServiceID(){
        return service_id_;
    }

    inline std::shared_ptr<ConnWriter> GetWriter(){
        return writer_;
    }
    inline std::shared_ptr<ConnReader> GetReader(){
        return reader_;
    }

public:
    Conn::Type type_;
    int fd_;
    uint32_t service_id_;
    

    std::shared_ptr<ConnReader> reader_;    
    std::shared_ptr<ConnWriter> writer_;
};


#endif  // __CONN_H__